package com.minelx.statementsplus;

import com.minelx.sqlstructures.statements.clause.Field;
import com.minelx.sqlstructures.statements.clause.Sql;

import java.util.function.Function;

public interface IChildSqlBuilder {
	IChildSqlBuilder addField(Field added);

	Sql asSql();

	String parentKey();

	default IChildSqlBuilder map(Function<String, String> mapper) {
		return new IChildSqlBuilder() {
			@Override
			public IChildSqlBuilder addField(Field added) {
				return IChildSqlBuilder.this.addField(added);
			}

			@Override
			public Sql asSql() {
				return IChildSqlBuilder.this.asSql().map(mapper);
			}

			@Override
			public String parentKey() {
				return IChildSqlBuilder.this.parentKey();
			}
		};
	}
}
